﻿var PageSize = 30;
var url = 'LogInf.aspx?';
var grid = null;

$(document).ready(function () {
    grid = $('#maingrid').ligerGrid({
        columns: [
            { display: '操作者', name: 'Whom', width: 100, type: 'text', align: 'center' },
            { display: '时间', name: 'Lpt', width: 150, type: 'text', align: 'left', isSort: false },
            { display: '备注', name: 'ActDesc', width: 400, type: 'text', align: 'left' },
            { display: 'Action 描述', name: 'ActName', width: 210, type: 'text', align: 'left' },
            { display: 'Function 描述', name: 'FunID', width: 150, type: 'text', align: 'left' }
        ],
        pageSize: PageSize, width: '100%', pageSizeOptions: [3,20, 25, 30, 35], pageStatMessage: 'Record:{from}-{to} Total:{total} Page Size:{pagesize}', height: '99%', rowHeight: '100%', url: url + 'Action=GetData', dataAction: 'server'
    });

    //初始化
    InitForm();
});

//初始化
function InitForm() {
    $('#FromTime').ligerDateEditor({ label: '起始', labelWidth: 70, width: 105, labelAlign: 'right' });
    $('#ToTime').ligerDateEditor({ label: '至', labelWidth: 60, width: 105, labelAlign: 'right' });
    $('#FunName').ligerComboBox({ lable: 'Function 描述', labelWidth: 100, width: 105, textField: 'FunDesc', valueField: 'FunID', url: 'LogInf.aspx?Action=LoadFunName', labelAlign: 'right' });
    $('#Action').ligerTextBox({ label: 'Action', labelWidth: 60, width: 105, labelAlign: 'right' });
    $('#Whom').ligerTextBox({ label: '操作者', labelWidth: 50, width: 105, labelAlign: 'right' });
    $('#BtnSearch').click(function () { BtnSearch_Click(); });

}

//查询数据
function BtnSearch_Click() {
    grid.options.newPage = 1;
    var fromtime = $('#FromTime').val();
    var totime = $('#ToTime').val();
    if (totime && fromtime) {
        if (fromtime > totime) {
            toastrWarning("From Date must be less than To Date/开始日期不能大于结束日期!");
            return false;
        }
    }

    grid.set('parms', {
        fromtime: $('#FromTime').val(),
        totime: $('#ToTime').val(),
        who: $('#Whom').val(),
        funid: $('#FunName').ligerComboBox().getValue(),
        actionName: $('#Action').val()
    });
    grid.loadData();
}